﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace UnityCommon
{
    public class Common
    {
        /// <summary>
        /// 生成ID
        /// </summary>
        /// <returns>45位时间与GUID结合的ID</returns>
        public static string GetId()
        {
            string guid = Guid.NewGuid().ToString("N").ToUpper();

            string dtString  = DateTime.Now.ToString("yyyyMMddHHmmss");

            string newid = (dtString + guid).Substring(0, 45);

            return newid;
        }

        /// <summary>
        /// 根据name获取连接字符串
        /// </summary>
        /// <param name="key">连接字符串配置文件name值</param>
        /// <returns></returns>
        public static string GetConstr(string key)
        {
            var conStr = ConfigurationManager.ConnectionStrings[key].ConnectionString;

            return conStr;
        }

        /// <summary>
        /// 加密字符串
        /// </summary>
        /// <returns>已加密的字符串</returns>
        public static string Encode()
        {
            return string.Empty;
        }

        /// <summary>
        /// 解密字符串
        /// </summary>
        /// <returns>加密前的明文</returns>
        public static string Decode()
        {
            return string.Empty;
        }
    }
}
